import {assembleTreeFromArray, getUserInfo} from "@/utils";

export const routerMeta = {
  login: {
    path: "/login",
    name: "login",
    label: "登录",
    meta: {
      ignoreToken: true,
      basic: true,
    },
    component: () => import("../page/Login"),
  },
  home: {
    path: "/admin/home",
    name: "admin.home",
    meta: {
      basic: true,
    },
    component: () => import("../layout/BodyAdmin"),
  },
  slash: {
    path: "/",
    name: "slash",
    redirect: "/login",
    meta: {
      ignoreToken: true,
      basic: true,
    },
    component: () => import("../page/Login"),
  },
  noPermission: {
    path: '/no/permission',
    name: 'noPermission',
    label: '无权限',
    meta: {
      ignoreToken: true,
      basic: true
    },
    component: () => import('../page/NoPermission')
  },
  notFound: {
    path: '/not/found',
    name: 'notFound',
    label: '页面找不到',
    meta: {
      ignoreToken: true,
      basic: true
    },
    component: () => import('../page/NotFound')
  },
  deviceBase: {
    path: '/admin/base',
    name: 'admin.base',
    relation: 'admin.home',
    meta: {
      title: '基础信息',
      label: '基础信息',
      icon: 'icon-lianjian1',
    },
  },
  deviceTypePlus: {
    path: '/admin/device/deviceClass',
    name: 'admin.base.deviceClass',
    relation: 'admin.base', // 用于组装侧边导航栏的嵌套结构
    meta: {
      title: '基础信息 | 设备大类',
      label: '设备大类',
      breadcrumb: [
        {
          title: '基础信息：设备大类'
        }
      ],
    },
    component: () => import("../page/baseData/DeviceClass.vue"),
  },
  deviceType: {
    path: '/admin/device/type',
    name: 'admin.base.deviceType',
    relation: 'admin.base', // 用于组装侧边导航栏的嵌套结构
    meta: {
      title: '基础信息 | 设备类别',
      label: '设备类别',
      breadcrumb: [
        {
          title: '基础信息：设备类别'
        }
      ],
    },
    component: () => import("../page/baseData/DeviceType"),
  },
  manufacturer: {
    path: '/admin/device/manufacturer',
    name: 'admin.base.manufacturer',
    relation: 'admin.base',
    meta: {
      title: '基础信息 | 设备厂家',
      label: '设备厂家',
      breadcrumb: [
        {
          title: '基础信息：设备厂家'
        }
      ],
    },
    component: () => import("../page/baseData/DeviceManufacturer"),
  },
  series: {
    path: '/admin/device/series',
    name: 'admin.base.series',
    relation: 'admin.base',
    meta: {
      title: '基础信息 | 设备系列',
      label: '设备系列',
      breadcrumb: [
        {
          title: '基础信息：设备系列'
        }
      ],
    },
    component: () => import("../page/baseData/DeviceSeries"),
  },
  model: {
    path: '/admin/device/model',
    name: 'admin.base.model',
    relation: 'admin.base',
    meta: {
      title: '基础信息 | 设备型号',
      label: '设备型号',
      breadcrumb: [
        {
          title: '基础信息：设备型号'
        }
      ],
    },
    component: () => import("../page/baseData/DeviceModel"),
  },
  deviceConfig: {
    path: '/admin/config',
    name: 'admin.config',
    relation: 'admin.home',
    meta: {
      title: '配置信息',
      label: '配置信息',
      icon: 'icon-shu',
    },
  },
  linkType: {
    path: '/admin/config/linkType',
    name: 'admin.config.linkType',
    relation: 'admin.config',
    meta: {
      title: '配置信息 | 链路类型',
      label: '链路类型',
      breadcrumb: [
        {
          title: '配置信息：链路类型'
        }
      ],
    },
    component: () => import("../page/relationData/LinkType"),
  },
  protocolType: {
    path: '/admin/config/protocolType',
    name: 'admin.config.protocolType',
    relation: 'admin.config',
    meta: {
      title: '配置信息 | 协议类别',
      label: '协议类别',
      breadcrumb: [
        {
          title: '配置信息：协议类别'
        }
      ],
    },
    component: () => import("../page/relationData/ProtocolType"),
  },
  analyzeFunc: {
    path: '/admin/config/analyzeFunc',
    name: 'admin.config.analyzeFunc',
    relation: 'admin.config',
    meta: {
      title: '配置信息 | 自定义函数',
      label: '自定义函数',
      breadcrumb: [
        {
          title: '配置信息：自定义函数'
        }
      ],
    },
    component: () => import("../page/relationData/AnalyzeFunc"),
  },
  generalFunc: {
    path: '/admin/config/generalFunc',
    name: 'admin.config.generalFunc',
    relation: 'admin.config',
    meta: {
      title: '配置信息 | 通用方法名',
      label: '通用方法名',
      breadcrumb: [
        {
          title: '配置信息：通用方法名'
        }
      ],
    },
    component: () => import("../page/relationData/GeneralFunc"),
  },
  generalParam: {
    path: '/admin/config/generalParam',
    name: 'admin.config.generalParam',
    relation: 'admin.config',
    meta: {
      title: '配置信息 | 通用参数名',
      label: '通用参数名',
      breadcrumb: [
        {
          title: '配置信息：通用参数名'
        }
      ],
    },
    component: () => import("../page/relationData/GeneralParam"),
  },
  metadataSetting: {
    path: '/admin/config/metadataSetting',
    name: 'admin.config.metadataSetting',
    relation: 'admin.config',
    meta: {
      title: '配置信息 | 设备元数据配置',
      label: '设备元数据',
      icon: 'icon-env_heating',
      breadcrumb: [
        {
          title: '配置信息：设备元数据配置'
        }
      ],
    },
    component: () => import("../page/relationData/metadataSetting/MetadataSetting"),
  },
  commonBase: {
    path: '/admin/common',
    name: 'admin.common',
    relation: 'admin.home',
    meta: {
      title: '通用配置',
      label: '通用配置',
      icon: 'icon-lianjian1',
    },
  },
  generalCommand: {
    path: '/admin/common/command',
    name: 'admin.common.command',
    relation: 'admin.common',
    meta: {
      title: '通用配置 | 通用命令',
      label: '通用命令',
      icon: 'icon-xunjian1',
      breadcrumb: [
        {
          title: '通用配置：通用命令'
        }
      ],
    },
    component: () => import("../page/relationData/generalCommand/GeneralCommand"),
  },
  generalProtocol: {
    path: '/admin/common/protocols',
    name: 'admin.common.protocols',
    relation: 'admin.common',
    notInNav: true,
    meta: {
      title: '通用配置 | 通用协议',
      label: '通用协议',
      icon: 'icon-xunjian1',
      breadcrumb: [
        {
          title: '通用配置：通用协议'
        }
      ],
    },
    component: () => import("../page/relationData/generalProtocol/GeneralProtocol"),
  },
  generalProtocolCommand: {
    path: '/admin/common/protocols/:pid/generalProtocolCommand',
    name: 'admin.common.protocols.generalProtocolCommand',
    relation: 'admin.common.protocols',
    meta: {
      title: '通用协议 | 协议命令',
      label: '协议命令',
      notInNav: true,
      breadcrumb: [
        {
          title: '通用协议',
          name: 'admin.common.protocols'
        },
        {
          title: '协议命令',
        },
      ]
    },
    component: () => import("../page/relationData/generalProtocol/partial/GeneralProtocolCommand.vue"),
  },
  generalCommandAdd: {
    path: '/admin/common/command/add',
    name: 'admin.common.command.add',
    relation: 'admin.common.command',
    meta: {
      title: '通用命令 | 新增通用命令',
      label: '新增通用命令',
      notInNav: true,
      breadcrumb: [
        {
          title: '通用命令',
          name: 'admin.common.command'
        },
        {
          title: '新增通用命令',
        },
      ]
    },
    component: () => import("../page/relationData/generalCommand/GeneralCommandAdd"),
  },
  generalCommandEdit: {
    path: '/admin/common/command/:gid/edit',
    name: 'admin.common.command.edit',
    relation: 'admin.common.command',
    meta: {
      title: '通用命令 | 编辑通用命令',
      label: '编辑通用命令',
      notInNav: true,
      breadcrumb: [
        {
          title: '通用命令',
          name: 'admin.common.command'
        },
        {
          title: '编辑通用命令',
        },
      ]
    },
    component: () => import("../page/relationData/generalCommand/GeneralCommandEdit"),
  },
  generalProCommandAdd: {
    path: '/admin/common/protocols/commands/add',
    name: 'admin.common.protocols.commands.add',
    relation: 'admin.common.protocols',
    meta: {
      title: '通用协议 | 新增通用命令',
      label: '新增通用命令',
      notInNav: true,
      breadcrumb: [
        {
          title: '通用协议',
          name: 'admin.common.protocols'
        },
        {
          title: '新增通用命令',
        },
      ]
    },
    component: () => import("../page/relationData/generalCommand/GeneralCommandAdd"),
  },
  generalProCommandEdit: {
    path: '/admin/common/protocols/commands/:gid/edit',
    name: 'admin.common.protocols.commands.edit',
    relation: 'admin.common.protocols',
    meta: {
      title: '通用协议 | 编辑通用命令',
      label: '编辑通用命令',
      notInNav: true,
      breadcrumb: [
        {
          title: '通用协议',
          name: 'admin.common.protocols'
        },
        {
          title: '编辑通用命令',
        },
      ]
    },
    component: () => import("../page/relationData/generalCommand/GeneralCommandEdit"),
  },

  // thirdPartyPlatform: {
  //   path: '/admin/third/party/platform',
  //   name: 'admin.thirdParty.platform',
  //   relation: 'admin.home',
  //   meta: {
  //     title: '平台对接',
  //     label: '平台对接',
  //     icon: 'icon-lianjian1',
  //     breadcrumb: [
  //       {
  //         title: '第三方平台对接'
  //       }
  //     ],
  //   },
  //   component: () => import("../page/thirdPartyPlatform/ThirdPartyPlatform.vue"),
  // },
  platformInterface: {
    path: '/admin/third/party/platform/:pid/interface',
    name: 'admin.thirdParty.platform.interface',
    relation: 'admin.thirdParty.platform',
    meta: {
      title: '平台对接',
      label: '平台对接',
      icon: 'icon-lianjian1',
      notInNav: true,
      breadcrumb: [
        {
          title: '第三方平台管理',
          name: 'admin.thirdParty.platform',
        },
        {
          title: '第三方平台对接'
        }
      ],
    },
    component: () => import("../page/thirdPartyPlatform/PlatformInterface.vue"),
  },
  platformInterfaceAdd: {
    path: '/admin/third/party/platform/:pid/interface/add',
    name: 'admin.thirdParty.platform.interface.add',
    relation: 'admin.thirdParty.platform.interface',
    meta: {
      title: '第三方平台对接 | 新增平台对接规则',
      label: '新增第三方对接',
      notInNav: true,
      breadcrumb: [
        {
          title: '第三方平台管理',
          name: 'admin.thirdParty.platform',
        },
        {
          title: '第三方平台对接',
          name: 'admin.thirdParty.platform.interface'
        },
        {
          title: '新增平台对接规则',
        },
      ],
    },
    component: () => import("../page/thirdPartyPlatform/PlatformInterfaceUpsert.vue"),
  },
  platformInterfaceEdit: {
    path: '/admin/third/party/platform/:pid/interface/:iid/edit',
    name: 'admin.thirdParty.platform.interface.edit',
    relation: 'admin.thirdParty.platform.interface',
    meta: {
      title: '第三方平台对接 | 编辑平台对接规则',
      label: '编辑平台对接规则',
      notInNav: true,
      breadcrumb: [
        {
          title: '第三方平台管理',
          name: 'admin.thirdParty.platform',
        },
        {
          title: '第三方平台对接',
          name: 'admin.thirdParty.platform.interface'
        },
        {
          title: '编辑平台对接规则',
        },
      ],
    },
    component: () => import("../page/thirdPartyPlatform/PlatformInterfaceUpsert.vue"),
  },
  protocol: {
    path: '/admin/protocol',
    name: 'admin.protocol',
    relation: 'admin.home',
    meta: {
      title: '设备协议',
      label: '设备协议',
      icon: 'icon-a-fuwujiaohuo',
      breadcrumb: [
        {
          title: '设备协议'
        }
      ],
    },
    component: () => import("../page/device/DeviceProtocolList"),
  },
  command: {
    path: '/admin/protocol/:pid/command',
    name: 'admin.protocol.command',
    relation: 'admin.protocol',
    meta: {
      title: '设备协议 | 设备命令',
      label: '设备命令',
      notInNav: true,
      breadcrumb: [
        {
          title: '设备协议',
          name: 'admin.protocol'
        },
        {
          title: '设备命令',
        },
      ]
    },
    component: () => import("../page/device/command/DeviceCommand"),
  },
  commandAdd: {
    path: '/admin/protocol/:pid/command/add',
    name: 'admin.protocol.command.add',
    relation: 'admin.protocol.command',
    meta: {
      title: '设备命令 | 新增设备命令',
      label: '新增设备命令',
      notInNav: true,
      breadcrumb: [
        {
          title: '设备协议',
          name: 'admin.protocol'
        },
        {
          title: '设备命令',
          name: 'admin.protocol.command'
        },
        {
          title: '新增设备命令',
        },
      ]
    },
    component: () => import("../page/device/command/DeviceCommandAdd"),
  },
  commandEdit: {
    path: '/admin/protocol/:pid/command/:cid/edit',
    name: 'admin.protocol.command.edit',
    relation: 'admin.protocol.command',
    meta: {
      title: '设备命令 | 编辑设备命令',
      label: '编辑设备命令',
      notInNav: true,
      breadcrumb: [
        {
          title: '设备协议',
          name: 'admin.protocol'
        },
        {
          title: '设备命令',
          name: 'admin.protocol.command'
        },
        {
          title: '编辑设备命令',
        },
      ]
    },
    component: () => import("../page/device/command/DeviceCommandEdit"),
  },
  commandClone: {
    path: '/admin/protocol/:pid/command/:cid/clone',
    name: 'admin.protocol.command.clone',
    relation: 'admin.protocol.command',
    meta: {
      title: '设备命令 | 复制设备命令',
      label: '复制设备命令',
      notInNav: true,
      breadcrumb: [
        {
          title: '设备协议',
          name: 'admin.protocol'
        },
        {
          title: '设备命令',
          name: 'admin.protocol.command'
        },
        {
          title: '复制设备命令',
        },
      ]
    },
    component: () => import("../page/device/command/DeviceCommandEdit"),
  },
  device: {
    path: '/admin/device',
    name: 'admin.device',
    relation: 'admin.home',
    meta: {
      isGuest: true, // 允许访客
      title: '设备集合',
      label: '设备集合',
      icon: 'icon-shebei',
      breadcrumb: [
        {
          title: '设备集合'
        }
      ],
    },
    component: () => import("../page/device/DeviceList"),
  },
  package: {
    path: '/admin/package',
    name: 'admin.package',
    relation: 'admin.home',
    meta: {
      isGuest: true, // 允许访客
      title: '安装包管理',
      label: '安装包管理',
      icon: 'icon-zhongkong',
      breadcrumb: [
        {
          title: '安装包管理'
        }
      ],
    },
    component: () => import("../page/package/PackageManagement.vue"),
  },
  publishSubscribe: {
    path: '/admin/publishSubscribe',
    name: 'admin.publishSubscribe',
    relation: 'admin.home',
    meta: {
      title: '发布订阅',
      label: '发布订阅',
      icon: 'icon-shu',
    },
  },

  attributeManagement: {
    path: '/admin/publishSubscribe/attributeManagement',
    name: 'admin.publishSubscribe.attributeManagement',
    relation: 'admin.publishSubscribe',
    meta: {
      title: '发布订阅 | 属性',
      label: '属性',
      breadcrumb: [
        {
          title: '发布订阅：属性'
        }
      ],
    },
    component: () => import("../page/assetManagement/AttributeManagement.vue"),
  },
  attributeAdd: {
    path: '/admin/publishSubscribe/attributeManagement/:type/add',
    name: 'admin.publishSubscribe.attributeManagement.add',
    relation: 'admin.publishSubscribe.attributeManagement',
    meta: {
      title: '属性 | 新增属性',
      label: '新增属性',
      breadcrumb: [
        {
          title: '属性',
          name: 'admin.publishSubscribe.attributeManagement'
        },
        {
          title: '新增属性',
        },
      ],
    },
    component: () => import("../page/assetManagement/partial/PublicSubscribeEdit.vue"),
  },
  attributeEdit: {
    path: '/admin/publishSubscribe/attributeManagement/:id/:type/edit',
    name: 'admin.publishSubscribe.attributeManagement.edit',
    relation: 'admin.publishSubscribe.attributeManagement',
    meta: {
      title: '属性 | 编辑属性',
      label: '编辑属性',
      breadcrumb: [
        {
          title: '属性',
          name: 'admin.publishSubscribe.attributeManagement'
        },
        {
          title: '编辑属性',
        },
      ],
    },
    component: () => import("../page/assetManagement/partial/PublicSubscribeEdit.vue"),
  },
  attributeDetail: {
    path: '/admin/publishSubscribe/attributeManagement/:id/:type/detail',
    name: 'admin.publishSubscribe.attributeManagement.detail',
    relation: 'admin.publishSubscribe.attributeManagement',
    meta: {
      title: '属性 | 查看详情',
      label: '查看详情',
      breadcrumb: [
        {
          title: '属性',
          name: 'admin.publishSubscribe.attributeManagement'
        },
        {
          title: '查看详情',
        },
      ],
    },
    component: () => import("../page/assetManagement/partial/PublicSubscribeDetail.vue"),
  },
   eventsManagement: {
    path: '/admin/publishSubscribe/eventsManagement',
    name: 'admin.publishSubscribe.eventsManagement',
    relation: 'admin.publishSubscribe',
    meta: {
      title: '发布订阅 | 事件',
      label: '事件',
      breadcrumb: [
        {
          title: '发布订阅：事件'
        }
      ],
    },
    component: () => import("../page/assetManagement/EventsManagement.vue"),
  },
  eventsAdd: {
    path: '/admin/publishSubscribe/eventsManagement/:type/add',
    name: 'admin.publishSubscribe.eventsManagement.add',
    relation: 'admin.publishSubscribe.eventsManagement',
    meta: {
      title: '事件 | 新增事件',
      label: '新增事件',
      breadcrumb: [
        {
          title: '事件',
          name: 'admin.publishSubscribe.eventsManagement'
        },
        {
          title: '新增事件',
        },
      ],
    },
    component: () => import("../page/assetManagement/partial/PublicSubscribeEdit.vue"),
  },
  eventsEdit: {
    path: '/admin/publishSubscribe/eventsManagement/:id/:type/edit',
    name: 'admin.publishSubscribe.eventsManagement.edit',
    relation: 'admin.publishSubscribe.eventsManagement',
    meta: {
      title: '事件 | 编辑事件',
      label: '编辑事件',
      breadcrumb: [
        {
          title: '事件',
          name: 'admin.publishSubscribe.eventsManagement'
        },
        {
          title: '编辑事件',
        },
      ],
    },
    component: () => import("../page/assetManagement/partial/PublicSubscribeEdit.vue"),
  },
  eventsDetail: {
    path: '/admin/publishSubscribe/eventsManagement/:id/:type/detail',
    name: 'admin.publishSubscribe.eventsManagement.detail',
    relation: 'admin.publishSubscribe.eventsManagement',
    meta: {
      title: '事件 | 查看详情',
      label: '查看详情',
      breadcrumb: [
        {
          title: '事件',
          name: 'admin.publishSubscribe.attributeManagement'
        },
        {
          title: '查看详情',
        },
      ],
    },
    component: () => import("../page/assetManagement/partial/PublicSubscribeDetail.vue"),
  },
  serviceManagement: {
    path: '/admin/publishSubscribe/serviceManagement',
    name: 'admin.publishSubscribe.serviceManagement',
    relation: 'admin.publishSubscribe',
    meta: {
      title: '发布订阅 | 服务',
      label: '服务',
      breadcrumb: [
        {
          title: '发布订阅：服务'
        }
      ],
    },
    component: () => import("../page/assetManagement/serviceManagement.vue"),
  },
  serviceAdd: {
    path: '/admin/publishSubscribe/serviceManagement/:type/add',
    name: 'admin.publishSubscribe.serviceManagement.add',
    relation: 'admin.publishSubscribe.serviceManagement',
    meta: {
      title: '服务 | 新增服务',
      label: '新增服务',
      breadcrumb: [
        {
          title: '服务',
          name: 'admin.publishSubscribe.serviceManagement'
        },
        {
          title: '新增服务',
        },
      ],
    },
    component: () => import("../page/assetManagement/partial/PublicSubscribeEdit.vue"),
  },
  serviceEdit: {
    path: '/admin/publishSubscribe/serviceManagement/:id/:type/edit',
    name: 'admin.publishSubscribe.serviceManagement.edit',
    relation: 'admin.publishSubscribe.serviceManagement',
    meta: {
      title: '服务 | 编辑服务',
      label: '编辑服务',
      breadcrumb: [
        {
          title: '服务',
          name: 'admin.publishSubscribe.serviceManagement'
        },
        {
          title: '编辑服务',
        },
      ],
    },
    component: () => import("../page/assetManagement/partial/PublicSubscribeEdit.vue"),
  },
  serviceDetail: {
    path: '/admin/publishSubscribe/serviceManagement/:id/:type/detail',
    name: 'admin.publishSubscribe.serviceManagement.detail',
    relation: 'admin.publishSubscribe.serviceManagement',
    meta: {
      title: '服务 | 查看详情',
      label: '查看详情',
      breadcrumb: [
        {
          title: '服务',
          name: 'admin.publishSubscribe.serviceManagement'
        },
        {
          title: '查看详情',
        },
      ],
    },
    component: () => import("../page/assetManagement/partial/PublicSubscribeDetail.vue"),
  },
  dataModelManagement: {
    path: '/admin/publishSubscribe/dataModelManagement',
    name: 'admin.publishSubscribe.dataModelManagement',
    relation: 'admin.publishSubscribe',
    meta: {
      title: '发布订阅 | 接口模型',
      label: '接口模型',
      breadcrumb: [
        {
          title: '发布订阅：接口模型'
        }
      ],
    },
    component: () => import("../page/assetManagement/DataModelManagement.vue"),
  },
  dataModelEdit: {
    path: '/admin/publishSubscribe/dataModelManagement/:id/edit',
    name: 'admin.publishSubscribe.dataModelManagement.edit',
    relation: 'admin.publishSubscribe.dataModelManagement',
    meta: {
      title: '接口模型 | 编辑数据模型',
      label: '接口模型',
      breadcrumb: [
        {
          title: '接口模型',
          name: 'admin.publishSubscribe.dataModelManagement'
        },
        {
          title: '编辑数据模型',
        },
      ],
    },
    component: () => import("../page/assetManagement/partial/DataModelEdit.vue"),
  },
  dataModelAdd: {
    path: '/admin/publishSubscribe/dataModelManagement/add',
    name: 'admin.publishSubscribe.dataModelManagement.add',
    relation: 'admin.publishSubscribe.dataModelManagement',
    meta: {
      title: '接口模型 | 新增数据模型',
      label: '接口模型',
      breadcrumb: [
        {
          title: '接口模型',
          name: 'admin.publishSubscribe.dataModelManagement'
        },
        {
          title: '新增数据模型',
        },
      ],
    },
    component: () => import("../page/assetManagement/partial/DataModelEdit.vue"),
  },
  webIDE: {
    path: '/admin/IDE',
    name: 'admin.IDE',
    relation: 'admin.home',
    meta: {
      isGuest: true, // 允许访客
      title: '平板编程',
      label: '平板编程',
      icon: 'icon-shu',
    },
  },
  project: {
    path: '/admin/IDE/project',
    name: 'admin.IDE.project',
    relation: 'admin.IDE',
    meta: {
      isGuest: true, // 允许访客
      title: '平板编程 | 项目管理',
      label: '项目管理',
      icon: 'icon-scaling',
      breadcrumb: [
        {
          title: '项目管理'
        }
      ],
    },
    component: () => import("../page/IDE/project/ProjectManagement.vue"),
  },
  commonAsset: {
    path: '/admin/IDE/project/common/asset',
    name: 'admin.IDE.project.common.asset',
    relation: 'admin.IDE.project',
    meta: {
      title: '项目管理 | 公共图片管理',
      label: '公共图片管理',
      icon: 'icon-scaling',
      notInNav: true,
      breadcrumb: [
        {
          title: '项目管理',
          name: 'admin.IDE.project'
        },
        {
          title: '公共图片管理'
        }
      ],
    },
    component: () => import("../page/IDE/asset/AssetManagement.vue"),
  },
  projectAsset: {
    path: '/admin/IDE/project/:pid/asset',
    name: 'admin.IDE.project.asset',
    relation: 'admin.IDE.project',
    meta: {
      title: '项目管理 | 项目图片管理',
      label: '项目图片管理',
      icon: 'icon-scaling',
      notInNav: true,
      isGuest: true, // 允许访客
      breadcrumb: [
        {
          title: '项目管理',
          name: 'admin.IDE.project'
        },
        {
          title: '项目图片管理'
        }
      ],
    },
    component: () => import("../page/IDE/asset/AssetManagement.vue"),
  },
  projectRoom: {
    path: '/admin/IDE/project/:pid/room',
    name: 'admin.IDE.project.room',
    relation: 'admin.IDE.project',
    meta: {
      title: '项目管理 | 房间管理',
      label: '房间管理',
      icon: 'icon-scaling',
      notInNav: true,
      isGuest: true, // 允许访客
      breadcrumb: [
        {
          title: '项目管理',
          name: 'admin.IDE.project'
        },
        {
          title: '房间管理',
        },
      ]
    },
    component: () => import("../page/IDE/room/RoomManagement.vue"),
  },
  roomAsset: {
    path: '/admin/IDE/project/:pid/room/:rid/asset',
    name: 'admin.IDE.project.room.asset',
    relation: 'admin.IDE.project.room',
    meta: {
      title: '项目管理 | 房间图片管理',
      label: '房间图片管理',
      icon: 'icon-scaling',
      notInNav: true,
      isGuest: true, // 允许访客
      breadcrumb: [
        {
          title: '项目管理',
          name: 'admin.IDE.project'
        },
        {
          title: '房间管理',
          name: 'admin.IDE.project.room',
        },
        {
          title: '房间图片管理'
        }
      ],
    },
    component: () => import("../page/IDE/asset/AssetManagement.vue"),
  },
  roomTemplate: {
    path: '/admin/IDE/room/template',
    name: 'admin.IDE.room.template',
    relation: 'admin.IDE',
    meta: {
      title: '平板编程 | 房间模版',
      label: '房间模版',
      icon: 'icon-scaling',
      breadcrumb: [
        {
          title: '房间模版'
        }
      ],
    },
    component: () => import("../page/IDE/template/TemplateManagement.vue"),
  },
  roomEditor: {
    path: '/admin/IDE/roomEditor/:projectName?/:rid',
    name: 'admin.IDE.roomEditor',
    meta: {
      title: '平板管理 | 房间编辑',
      label: '房间编辑',
      basic: true,
      isGuest: true, // 允许访客
    },
    component: () => import('../page/IDE/room/RoomEditor.vue')
  },
  component: {
    path: '/admin/IDE/component',
    name: 'admin.IDE.component',
    relation: 'admin.IDE',
    meta: {
      title: '平板编程 | 组件管理',
      label: '组件管理',
      icon: 'icon-scaling',
      breadcrumb: [
        {
          title: '组件管理'
        }
      ],
    },
    component: () => import("../page/IDE/component/ComponentManagement.vue"),
  },
  compositeWidget : {
    path: '/admin/IDE/compositeWidget',
    name: 'admin.IDE.compositeWidget',
    relation: 'admin.IDE',
    meta: {
      title: '平板编程 | 小组件管理',
      label: '小组件管理',
      icon: 'icon-scaling',
      breadcrumb: [
        {
          title: '小组件管理'
        }
      ],
    },
    component: () => import("../page/IDE/component/CompositeWidgetManagement.vue"),
  },
  componentEditor: {
    path: '/admin/IDE/componentEditor/:cid',
    name: 'admin.IDE.componentEditor',
    meta: {
      title: '组件管理 | 组件编辑',
      label: '房间编辑',
      basic: true
    },
    component: () => import('../page/IDE/component/ComponentEditor.vue')
  },
  // componentReview: {
  //   path: '/admin/IDE/componentReview',
  //   name: 'admin.IDE.componentReview',
  //   relation: 'admin.IDE',
  //   meta: {
  //     title: '平板编程 | 组件审核',
  //     label: '组件审核',
  //     icon: 'icon-scaling',
  //     breadcrumb: [
  //       {
  //         title: '组件审核'
  //       }
  //     ],
  //   },
  //   component: () => import("../page/IDE/component/ComponentReview.vue"),
  // },
  // componentRelease: {
  //   path: '/admin/IDE/componentRelease',
  //   name: 'admin.IDE.componentRelease',
  //   relation: 'admin.IDE',
  //   meta: {
  //     title: '平板编程 | 组件发布',
  //     label: '组件发布',
  //     icon: 'icon-scaling',
  //     breadcrumb: [
  //       {
  //         title: '组件发布'
  //       }
  //     ],
  //   },
  //   component: () => import("../page/IDE/component/ComponentRelease.vue"),
  // },
  ipad: {
    path: '/admin/IDE/ipad',
    name: 'admin.IDE.ipad',
    relation: 'admin.IDE',
    meta: {
      title: '平板编程 | 平板管理',
      label: '平板管理',
      icon: 'icon-scaling',
      breadcrumb: [
        {
          title: '平板管理'
        }
      ],
    },
    component: () => import("../page/IDE/ipad/IpadManagement.vue"),
  },
  operationLog: {
    path: '/admin/log',
    name: 'admin.log',
    relation: 'admin.home',
    meta: {
      // superAdmin: true, // 暂时只允许管理员访问
      title: '操作日志',
      label: '操作日志',
      icon: 'icon-shezhi',
      breadcrumb: [
        {
          title: '操作日志'
        }
      ],
    },
    component: () => import("../page/operationLog/OperationLog"),
  },
  user: {
    path: '/admin/user',
    name: 'admin.user',
    relation: 'admin.home',
    meta: {
      superAdmin: true, // 暂时只允许管理员访问
      title: '设置 | 用户管理',
      label: '用户管理',
      icon: 'icon-yonghu',
      breadcrumb: [
        {
          title: '设置：用户管理'
        }
      ],
    },
    component: () => import("../page/account/UserManagement"),
  },

};

// 路由元数据扁平化
export function routerMetaPlain(filterNotNav = false) {
  const destRouterMeta = [];
  const isAdmin = getUserInfo().isAdmin;
  Object.values(routerMeta).forEach((route) => {
    const {meta = {}} = route;
    const {basic = false, notInNav = false, superAdmin = isAdmin} = meta;
    if (basic) {
      destRouterMeta.push(route);
    } else {
      // if (superAdmin && !isAdmin) return;
      // 给业务路由添加 parent
      const destRoute = {...route, parent: 'admin.home'};
      if (!filterNotNav) {
        destRouterMeta.push(destRoute);
      } else {
        !notInNav && destRouterMeta.push(destRoute);
      }
    }
  });
  return destRouterMeta;
}

// 根据用户登录返回的权限，组装侧边导航信息（级联结构）
export function initMenuData() {
  const routes = assembleTreeFromArray({ // 获取路由的树形结构
    srcData: routerMetaPlain(true),
    parentKey: 'relation',
    childKey: 'name'
  });
  const menuRoute = routes.find(r => r.name === 'admin.home');
  return menuRoute.children || [];
}
